<!doctype html>
<html lang="en">
  <head>
    ${require('./_head.html') 
      title="Modal" 
      description="A flexible container with graceful spacings across devices and viewports."
      canonical="modal.html"
    }
  </head>

  <body>
    ${require('./_nav.html')}
    
    <main class="container" id="docs">
      ${require('./_sidebar.html') active="modal-link"}
      
      <div role="document">
        <section id="modal">
          <hgroup>
            <h1>Modal</h1>
            <h2>The classic modal element with graceful spacings across devices and viewports.</h2>
          </hgroup>

          <p>Modals are built with <code>&lt;<b>dialog</b>&gt;</code> as a wrapper and <code>&lt;<b>article</b>&gt;</code> as a content container.</p>
          <p>Inside <code>&lt;<b>header</b>&gt;</code>, <code>&lt;<b>a</b> <i>class</i>=<u>"close"</u>&gt;</code> is defined to <code><i>float</i>: <u>right</u>;</code> allowing a close icon to be top aligned with a title.</p>

          <dialog class="example" open>
            <article>
              <header>
                <a href="#close" aria-label="Close" class="close" onclick="event.preventDefault()"></a>
                <p>Modal title</p>
              </header>
              <p>
                Nunc nec ligula a tortor sollicitudin dictum in vel enim. 
                Quisque facilisis turpis vel eros dictum aliquam et nec turpis. 
                Sed eleifend a dui nec ullamcorper. 
                Praesent vehicula lacus ac justo accumsan ullamcorper.
              </p>
            </article>
          </dialog>

<pre><code>&lt;<b>dialog</b> <i>open</i>&gt;
  &lt;<b>article</b>&gt;
    &lt;<b>header</b>&gt;
      &lt;<b>a</b> <i>href</i>=<u>"#close"</u> <i>aria-label</i>=<u>"Close"</u> <i>class</i>=<u>"close"</u>&gt;&lt;/<b>a</b>&gt;
      Modal title
    &lt;/<b>header</b>&gt;
    &lt;<b>p</b>&gt;
      Nunc nec ligula a tortor sollicitudin dictum in vel enim. 
      Quisque facilisis turpis vel eros dictum aliquam et nec turpis. 
      Sed eleifend a dui nec ullamcorper. 
      Praesent vehicula lacus ac justo accumsan ullamcorper.
    &lt;/<b>p</b>&gt;
  &lt;/<b>article</b>&gt;
&lt;/<b>dialog</b>&gt;</code></pre>

          <p>Inside <code>&lt;<b>footer</b>&gt;</code>, the content is right aligned by default.</p>

          <dialog class="example" open>
            <article>
              <h3>Confirm your action!</h3>
              <p>
                Mauris non nibh vel nisi sollicitudin malesuada. 
                Donec ut sagittis erat. Praesent eu eros felis. 
                Ut consectetur placerat pulvinar.
              </p>
              <footer>
                <a href="#cancel" role="button" class="secondary" onclick="event.preventDefault()">Cancel</a><a href="#confirm" role="button" onclick="event.preventDefault()">Confirm</a>
              </footer>
            </article>
          </dialog>


<pre><code>&lt;<b>dialog</b> <i>open</i>&gt;
  &lt;<b>article</b>&gt;
    &lt;<b>h3</b>&gt;Confirm your action!&lt;/<b>h3</b>&gt;
    &lt;<b>p</b>&gt;
      Mauris non nibh vel nisi sollicitudin malesuada. 
      Donec ut sagittis erat. Praesent eu eros felis. 
      Ut consectetur placerat pulvinar.
    &lt;/<b>p</b>&gt;
    &lt;<b>footer</b>&gt;
      &lt;<b>a</b> <i>href</i>=<u>"#cancel"</u> <i>role</i>=<u>"button"</u> <i>class</i>=<u>"secondary"</u>&gt;Cancel&lt;/<b>a</b>&gt;
      &lt;<b>a</b> <i>href</i>=<u>"#confirm"</u> <i>role</i>=<u>"button"</u>&gt;Confirm&lt;/<b>a</b>&gt;
    &lt;/<b>footer</b>&gt;
  &lt;/<b>article</b>&gt;
&lt;/<b>dialog</b>&gt;</code></pre>

          <hgroup>
            <h2>Live demo</h2>
            <h3>Toggle a modal by clicking the button below.</h3>
          </hgroup>

          <article>
            <button class="contrast" data-target="modal-example" onclick="toggleModal(event)">Launch demo modal</button>
            <footer class="code">

<pre><code><em>&lt;!-- Button to trigger the modal --&gt;</em>
&lt;<b>button</b> <i>class</i>=<u>"contrast"</u>
  <i>data-target</i>=<u>"modal-example"</u>
  <i>onClick</i>=<u>"toggleModal(event)"</u>&gt;
  Launch demo modal
&lt;/<b>button</b>&gt;

<em>&lt;!-- Modal --&gt;</em>
&lt;<b>dialog</b> <i>id</i>=<u>"modal-example"</u>&gt;
  &lt;<b>article</b>&gt;
    &lt;<b>a</b> <i>href</i>=<u>"#close"</u>
      <i>aria-label</i>=<u>"Close"</u>&gt;
      <i>class</i>=<u>"close"</u>
      <i>data-target</i>=<u>"modal-example"</u>
      <i>onClick</i>=<u>"toggleModal(event)"</u>&gt;
    &lt;/<b>a</b>&gt;
    &lt;<b>h3</b>&gt;Confirm your action!&lt;/<b>h3</b>&gt;
    &lt;<b>p</b>&gt;
      Cras sit amet maximus risus. 
      Pellentesque sodales odio sit amet augue finibus pellentesque. 
      Nullam finibus risus non semper euismod.
    &lt;/<b>p</b>&gt;
    &lt;<b>footer</b>&gt;
      &lt;<b>a</b> <i>href</i>=<u>"#cancel"</u>
        <i>role</i>=<u>"button"</u>&gt;
        <i>class</i>=<u>"secondary"</u>
        <i>data-target</i>=<u>"modal-example"</u>
        <i>onClick</i>=<u>"toggleModal(event)"</u>&gt;
        Cancel
      &lt;/<b>a</b>&gt;
      &lt;<b>a</b> <i>href</i>=<u>"#confirm"</u>
        <i>role</i>=<u>"button"</u>
        <i>data-target</i>=<u>"modal-example"</u>
        <i>onClick</i>=<u>"toggleModal(event)"</u>&gt;
        Confirm
      &lt;/<b>a</b>&gt;
    &lt;/<b>footer</b>&gt;
  &lt;/<b>article</b>&gt;
&lt;/<b>dialog</b>&gt;</code></pre>

            </footer>
          </article>

          <p>Pico does not include JavaScript code. You will need to implement your JS to interact with modals.</p>

          <p>As a starting point, you can look at the JavaScript used in this documentation: <a href="https://github.com/picocss/pico/blob/master/docs/js/modal.js">js/modal.js</a>.</p>

          <p>To make a modal appear, add the <code><i>open</i></code> attribute to the <code>&lt;<b>dialog</b></u>&gt;</code> container.</p>

<pre><code><em>&lt;!-- Open modal--&gt;</em>
&lt;<b>dialog</b> <i>open</i>&gt;
  &lt;<b>article</b>&gt;
  <em>…</em>
  &lt;/<b>article</b>&gt;
&lt;/<b>dialog</b>&gt;

<em>&lt;!-- Modal closed --&gt;</em>
&lt;<b>dialog</b>&gt;
  &lt;<b>article</b>&gt;
    <em>…</em>
  &lt;/<b>article</b>&gt;
&lt;/<b>dialog</b>&gt;
</code></pre>

          <h2>Utilities</h2>

          <p>Modals come with 3 utility classes.</p>

          <p><code>.modal-is-open</code> prevents any scrolling and interactions below the modal.</p>

<pre><code><em>&lt;!doctype html&gt;</em>
&lt;<b>html</b> <i>class</i>=<u>"modal-is-open"</u>&gt;
  <em>…</em>
&lt;/<b>html</b>&gt;</code></pre>

          <p><code>.modal-is-opening</code> brings an opening animation.</p>

<pre><code><em>&lt;!doctype html&gt;</em>
&lt;<b>html</b> <i>class</i>=<u>"modal-is-open modal-is-opening"</u>&gt;
  <em>…</em>
&lt;/<b>html</b>&gt;</code></pre>
        
          <p><code>.modal-is-closing</code> brings a closing animation.</p>

<pre><code><em>&lt;!doctype html&gt;</em>
&lt;<b>html</b> <i>class</i>=<u>"modal-is-open modal-is-closing"</u>&gt;
  <em>…</em>
&lt;/<b>html</b>&gt;</code></pre>

        </section>

        ${require('./_footer.html')}
        
      </div>
    </main>

    <dialog id="modal-example">
      <article>
        <a href="#close" aria-label="Close" class="close" data-target="modal-example" onclick="toggleModal(event)"></a>
        <h3>Confirm your action!</h3>
        <p>Cras sit amet maximus risus. Pellentesque sodales odio sit amet augue finibus pellentesque. Nullam finibus risus non semper euismod.</p>
        <footer>
          <a href="#cancel" role="button" class="secondary" data-target="modal-example" onclick="toggleModal(event)">Cancel</a><a href="#confirm" role="button" data-target="modal-example" onclick="toggleModal(event)">Confirm</a>
        </footer>
      </article>
    </dialog>

    <script src="js/commons.min.js"></script>
    <script src="js/modal.min.js"></script>
    
    </script>
  </body>
</html>